package com.axt.dbaudit.action.query.report;

import java.util.List;

import org.apache.struts2.json.annotations.JSON;

import com.axt.dbaudit.action.query.QueryBaseAction;
import com.axt.dbaudit.bean.query.report.QueryReportAlarmBean;
import com.axt.dbaudit.model.query.report.AlarmByClientIp;
import com.axt.dbaudit.model.query.report.AlarmByClientIpSort;
import com.axt.dbaudit.model.query.report.AlarmByTime;
import com.axt.soa.msg.types.MsgParam;

public class QueryReportAlarmAction extends QueryBaseAction{
	private QueryReportAlarmBean queryReportAlarmBean = new QueryReportAlarmBean();
	
	private List<AlarmByTime> alarmByTimes = null;
	private List<AlarmByClientIp> alarmByClientIps = null;
	private List<AlarmByClientIpSort> alarmByClientIpSorts = null;
	
	@JSON(name="alarmbytimes")
	public List<AlarmByTime> getAlarmByTimes() {
		return alarmByTimes;
	}
	
	@JSON(name="alarmbyclientip")
	public List<AlarmByClientIp> getAlarmByClientIps() {
		return alarmByClientIps;
	}
	
	@JSON(name="alarmbyclientipsort")
	public List<AlarmByClientIpSort> getAlarmByClientIpSorts() {
		return alarmByClientIpSorts;
	}
	
	public void setAlarmByTimes(List<AlarmByTime> alarmByTimes) {
		this.alarmByTimes = alarmByTimes;
	}

	public void setAlarmByClientIps(List<AlarmByClientIp> alarmByClientIps) {
		this.alarmByClientIps = alarmByClientIps;
	}

	public void setAlarmByClientIpSorts(
			List<AlarmByClientIpSort> alarmByClientIpSorts) {
		this.alarmByClientIpSorts = alarmByClientIpSorts;
	}
	
	/* 停止查询 */
	public String stopQuery() {
		
		/* 停止查询索引 */
		queryReportAlarmBean.stopQueryIndices(serverPath);
		
		setErrcode(queryReportAlarmBean.getErrcode());
		setErrinfo(queryReportAlarmBean.getErrinfo());
		
		return MsgParam.SUCCESS;

	}
	
	// 按时间统计报警
	public String StatForAlarmsByTimeRgn() {

		/* 查询索引 */
		queryReportAlarmBean.StatForAlarmsByTimeRgn(serverPath, filters, maxRowNum);
		
		setErrcode(queryReportAlarmBean.getErrcode());
		setErrinfo(queryReportAlarmBean.getErrinfo());
		
		return MsgParam.SUCCESS;
	}

	/* 按时间统计报警  查询结果 */
	public String StatForAlarmsByTimeRgnData() {

		/* 查询数据 */
		queryReportAlarmBean.StatForAlarmsByTimeRgnData(serverPath, filters, maxRowNum);
		
		setAlarmByTimes(queryReportAlarmBean.getAlarmByTimes());
		setErrcode(queryReportAlarmBean.getErrcode());
		setErrinfo(queryReportAlarmBean.getErrinfo());
		
		return MsgParam.SUCCESS;
	}
	
	// 按客户端IP统计报警
	public String StatForAlarmsByCliIP() {

		/* 查询索引 */
		queryReportAlarmBean.StatForAlarmsByCliIP(serverPath, filters, maxRowNum);
		
		setErrcode(queryReportAlarmBean.getErrcode());
		setErrinfo(queryReportAlarmBean.getErrinfo());
		
		return MsgParam.SUCCESS;
	}

	/* 按客户端IP统计报警  查询结果 */
	public String StatForAlarmsByCliIPData() {

		/* 查询数据 */
		queryReportAlarmBean.StatForAlarmsByCliIPData(serverPath, filters, maxRowNum);
		
		setAlarmByClientIps(queryReportAlarmBean.getAlarmByClientIps());
		setErrcode(queryReportAlarmBean.getErrcode());
		setErrinfo(queryReportAlarmBean.getErrinfo());
		
		return MsgParam.SUCCESS;
	}
	
	// 根据客户端IP排序 全部报警排序
	public String SortForAlarmsByCliIP() {

		/* 查询索引 */
		queryReportAlarmBean.SortForAlarmsByCliIP(serverPath, filters, maxRowNum);
		
		setErrcode(queryReportAlarmBean.getErrcode());
		setErrinfo(queryReportAlarmBean.getErrinfo());
		
		return MsgParam.SUCCESS;
	}

	/* 根据客户端IP排序 全部报警排序  查询结果 */
	public String SortForAlarmsByCliIPData() {

		/* 查询数据 */
		queryReportAlarmBean.SortForAlarmsByCliIPData(serverPath, filters, maxRowNum);
		
		setAlarmByClientIpSorts(queryReportAlarmBean.getAlarmByClientIpSorts());
		setErrcode(queryReportAlarmBean.getErrcode());
		setErrinfo(queryReportAlarmBean.getErrinfo());
		
		return MsgParam.SUCCESS;
	}
	
	// 根据客户端IP排序 高排序
	public String SortForAlarmsByCliIPHigh() {

		/* 查询索引 */
		queryReportAlarmBean.SortForAlarmsByCliIPHigh(serverPath, filters, maxRowNum);
		
		setErrcode(queryReportAlarmBean.getErrcode());
		setErrinfo(queryReportAlarmBean.getErrinfo());
		
		return MsgParam.SUCCESS;
	}

	/* 根据客户端IP排序 高报警排序  查询结果 */
	public String SortForAlarmsByCliIPHighData() {

		/* 查询数据 */
		queryReportAlarmBean.SortForAlarmsByCliIPHighData(serverPath, filters, maxRowNum);
		
		setAlarmByClientIpSorts(queryReportAlarmBean.getAlarmByClientIpSorts());
		setErrcode(queryReportAlarmBean.getErrcode());
		setErrinfo(queryReportAlarmBean.getErrinfo());
		
		return MsgParam.SUCCESS;
	}
	
	// 根据客户端IP排序 中排序
	public String SortForAlarmsByCliIPMid() {

		/* 查询索引 */
		queryReportAlarmBean.SortForAlarmsByCliIPMid(serverPath, filters, maxRowNum);
		
		setErrcode(queryReportAlarmBean.getErrcode());
		setErrinfo(queryReportAlarmBean.getErrinfo());
		
		return MsgParam.SUCCESS;
	}

	/* 根据客户端IP排序 中报警排序  查询结果 */
	public String SortForAlarmsByCliIPMidData() {

		/* 查询数据 */
		queryReportAlarmBean.SortForAlarmsByCliIPMidData(serverPath, filters, maxRowNum);
		
		setAlarmByClientIpSorts(queryReportAlarmBean.getAlarmByClientIpSorts());
		setErrcode(queryReportAlarmBean.getErrcode());
		setErrinfo(queryReportAlarmBean.getErrinfo());
		
		return MsgParam.SUCCESS;
	}
	
	// 根据客户端IP排序 低排序
	public String SortForAlarmsByCliIPLow() {

		/* 查询索引 */
		queryReportAlarmBean.SortForAlarmsByCliIPLow(serverPath, filters, maxRowNum);
		
		setErrcode(queryReportAlarmBean.getErrcode());
		setErrinfo(queryReportAlarmBean.getErrinfo());
		
		return MsgParam.SUCCESS;
	}

	/* 根据客户端IP排序 低报警排序  查询结果 */
	public String SortForAlarmsByCliIPLowData() {

		/* 查询数据 */
		queryReportAlarmBean.SortForAlarmsByCliIPLowData(serverPath, filters, maxRowNum);
		
		setAlarmByClientIpSorts(queryReportAlarmBean.getAlarmByClientIpSorts());
		setErrcode(queryReportAlarmBean.getErrcode());
		setErrinfo(queryReportAlarmBean.getErrinfo());
		
		return MsgParam.SUCCESS;
	}
}
